package com.registerandlogin;

import java.sql.*;




public class DBUtil {
	static String user = "root";
	static String password = "1242003108";
	static String DataBaseName = "student";
	
	
	static String url = "jdbc:mysql://127.0.0.1:3306/" + DataBaseName+"?serverTimezone=UTC";;
	
	static{
		try{
			Class.forName("com.mysql.cj.jdbc.Driver");
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static Connection getConnection(){
		Connection conn = null;
		
		try {
			conn = DriverManager.getConnection(url,user,password);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return conn;
	}


	public static void closeJDBC(ResultSet rs,Statement stmt,Connection conn){
		if (rs != null) {
			try {
				rs.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		if (stmt!= null) {
			try {
				stmt.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
			
		}
		if (conn!=null) {
			try {
				conn.close();
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
	}

	
	
}
